
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>GraphQL 介绍 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="chapter1.html" />
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter active" data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    GraphQL 介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="chapter1.html">
            
                <a href="chapter1.html">
            
                    
                    查询语句和转变
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >GraphQL 介绍</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="graphql&#x4ECB;&#x7ECD;">GraphQL&#x4ECB;&#x7ECD;</h1>
<blockquote>
<p>&#x5728;&#x8FD9;&#x4E00;&#x7CFB;&#x5217;&#x7684;&#x6587;&#x7AE0;&#x4E2D;&#x6211;&#x4EEC;&#x5C06;&#x5B66;&#x4E60;GraphQL&#x662F;&#x600E;&#x6837;&#x5DE5;&#x4F5C;&#x7684;&#x3002;&#x60F3;&#x8981;&#x901A;&#x8FC7;&#x6587;&#x6863;&#x77E5;&#x9053;&#x5982;&#x4F55;&#x6253;&#x9020;GraphQL&#x670D;&#x52A1;&#xFF1F;&#x8FD9;&#x91CC;&#x6709;&#x4E00;&#x4E9B;&#x5E93;&#x53EF;&#x4EE5;&#x5E2E;&#x52A9;&#x4F60;&#x5728;&#x5F88;&#x591A;&#x4E0D;&#x540C;&#x8BED;&#x8A00;&#x91CC;&#x5B9E;&#x73B0;GraphQL&#x3002;</p>
</blockquote>
<p>GraphQL&#x662F;&#x4E00;&#x79CD;&#x652F;&#x6301;API&#x7684;&#x67E5;&#x8BE2;&#x8BED;&#x8A00;&#xFF0C;&#x540C;&#x65F6;&#x4E5F;&#x662F;&#x6839;&#x636E;&#x4F60;&#x7684;&#x6570;&#x636E;&#x81EA;&#x5B9A;&#x4E49;&#x7C7B;&#x578B;&#xFF08;type&#xFF09;&#x7CFB;&#x7EDF;&#x7684;&#x670D;&#x52A1;&#x7AEF;&#x70ED;&#x6267;&#x884C;&#x67E5;&#x8BE2;&#x3002;GraphQL&#x5E76;&#x6CA1;&#x6709;&#x7ED1;&#x5B9A;&#x4EFB;&#x4F55;&#x6570;&#x636E;&#x5E93;&#x6216;&#x5185;&#x5B58;&#x5F15;&#x64CE;&#xFF0C;&#x800C;&#x662F;&#x5B8C;&#x5168;&#x57FA;&#x4E8E;&#x4F60;&#x73B0;&#x6709;&#x7684;&#x4EE3;&#x7801;&#x548C;&#x6570;&#x636E;&#x3002;</p>
<p>&#x4E00;&#x4E2A;GraphQL&#x670D;&#x52A1;&#x662F;&#x901A;&#x8FC7;&#x5B9A;&#x4E49;&#x7C7B;&#x578B;&#xFF08;type&#xFF09;&#x548C;type&#x4E0A;&#x7684;fields, &#x7136;&#x540E;&#x7ED9;&#x6BCF;&#x4E00;&#x4E2A;type&#x91CC;&#x7684;fields&#x63D0;&#x4F9B;&#x51FD;&#x6570;&#x6765;&#x521B;&#x5EFA;&#x7684;&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x4E00;&#x4E2A;GraphQL&#x670D;&#x52A1;&#x8981;&#x544A;&#x8BC9;&#x6211;&#x4EEC;&#x8C01;&#x662F;&#x5DF2;&#x767B;&#x9646;&#x7684;&#x7528;&#x6237;&#xFF08;&#x6211;&#x81EA;&#x5DF1;&#xFF09;&#x4EE5;&#x53CA;&#x7528;&#x6237;&#x7684;&#x540D;&#x5B57;&#x53EF;&#x80FD;&#x4F1A;&#x662F;&#x8FD9;&#x6837;&#x7684;&#xFF1A;</p>
<pre><code>type Query {
  me: User
}

type User {
  id: ID
  name: String
}
</code></pre><p>&#x5BF9;&#x5E94;&#x6BCF;&#x4E00;&#x4E2A;type&#x91CC;&#x7684;field&#x7684;&#x51FD;&#x6570;&#xFF1A;</p>
<pre><code>function Query_me(request) {
  return request.auth.user;
}

function User_name(user) {
  return user.getName();
}
</code></pre><p>&#x5F53;&#x4E00;&#x4E2A;GraphQL&#x670D;&#x52A1;&#x6B63;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#xFF08;&#x901A;&#x5E38;&#x5728;&#x4E00;&#x4E2A;web&#x670D;&#x52A1;&#x7684;URL&#x4E0A;&#xFF09;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x53D1;&#x9001;GraphQL&#x8BED;&#x53E5;&#x6765;&#x8FDB;&#x884C;&#x9A8C;&#x8BC1;&#x548C;&#x6267;&#x884C;&#x3002;&#x4E00;&#x4E2A;&#x6536;&#x5230;&#x7684;&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x4F1A;&#x9996;&#x5148;&#x88AB;&#x68C0;&#x67E5;&#x4EE5;&#x4FDD;&#x8BC1;&#x5B83;&#x88AB;&#x6307;&#x5411;&#x88AB;&#x5B9A;&#x4E49;&#x7684;types&#x548C;fields&#xFF0C;&#x7136;&#x540E;&#x8FD0;&#x884C;&#x63D0;&#x4F9B;&#x7684;&#x51FD;&#x6570;&#x6765;&#x6267;&#x884C;&#x7ED3;&#x679C;&#x3002;</p>
<p>&#x6BD4;&#x5982;&#x8FD9;&#x4E2A;&#x8BED;&#x53E5;&#xFF1A;</p>
<pre><code>{
  me {
    name
  }
}
</code></pre><p>&#x80FD;&#x591F;&#x751F;&#x6210;&#x4EE5;&#x4E0B;JSON&#x7ED3;&#x679C;&#xFF1A;</p>
<pre><code>{
  &quot;me&quot;: {
    &quot;name&quot;: &quot;Luke Skywalker&quot;
  }
}
</code></pre><p>&#x5B66;&#x4E60;&#x66F4;&#x591A;&#x5173;&#x4E8E;GraphQL - &#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#xFF0C;&#x7C7B;&#x578B;&#x7CFB;&#x7EDF;&#xFF0C;GraphQL&#x670D;&#x52A1;&#x5982;&#x4F55;&#x5DE5;&#x4F5C;&#xFF0C;&#x4EE5;&#x53CA;&#x7528;GraphQL&#x6765;&#x89E3;&#x51B3;&#x4E00;&#x822C;&#x95EE;&#x9898;&#x7684;&#x6700;&#x4F73;&#x5B9E;&#x8DF5; - &#x8FD9;&#x4E9B;&#x5C31;&#x662F;&#x8FD9;&#x4E2A;&#x90E8;&#x5206;&#x6240;&#x5199;&#x7684;&#x5185;&#x5BB9;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="chapter1.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 查询语句和转变">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"GraphQL 介绍","level":"1.1","depth":1,"next":{"title":"查询语句和转变","level":"1.2","depth":1,"path":"chapter1.md","ref":"chapter1.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"README.md","mtime":"2017-02-15T11:35:55.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-02-15T11:46:59.447Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

